/**
 * 
 */
package cultu.mail.service.impl;

import org.springframework.mail.MailException;
import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;

import cultu.mail.service.MailService;

/**
 * The Class MailServiceImpl.
 *
 * @author Marc-Antoine
 */
public class MailServiceImpl implements MailService
{

  /**
   * The mail sender.
   */
  private MailSender mailSenderNoReply;

  /**
   * The mail sender.
   */
  private MailSender mailSenderContact;

  /**
   * The simple mail message.
   */
  private SimpleMailMessage templateMessage;

  /**
   * {@inheritDoc}
   */
  public void sendMailNoReply(String dest, String subject, String content)
  {
    // TODO Auto-generated method stub
    SimpleMailMessage msg = new SimpleMailMessage(this.templateMessage);

    msg.setTo(dest);
    msg.setText(content);

    try{
      mailSenderNoReply.send(msg);
    } catch(MailException ex) {
      // simply log it and go on...

    }
  }

  /**
   * {@inheritDoc}
   */
  public void sendMailContact(String dest, String subject, String content)
  {
    // TODO Auto-generated method stub
    SimpleMailMessage msg = new SimpleMailMessage(this.templateMessage);

    msg.setTo(dest);
    msg.setText(content);

    try{
      mailSenderContact.send(msg);
    } catch(MailException ex) {
      // simply log it and go on...

    }
  }

  /**
   * Set mail sender.
   *
   * @param mailSenderNoReply the new mail sender no reply
   */
  public void setMailSenderNoReply(MailSender mailSenderNoReply)
  {
    this.mailSenderNoReply = mailSenderNoReply;
  }

  /**
   * Set mail sender.
   *
   * @param mailSenderContact the new mail sender contact
   */
  public void setMailSenderContact(MailSender mailSenderContact)
  {
    this.mailSenderContact = mailSenderContact;
  }

  /**
   * Set template message.
   * @param templateMessage the template mesage to set.
   */
  public void setTemplateMessage(SimpleMailMessage templateMessage)
  {
    this.templateMessage = templateMessage;
  }
}
